package com.dong.cjlibproxy;


import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class DemoMethodInterceptor implements MethodInterceptor {

    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("before");
        Object result = null;
        try{
            result=methodProxy.invokeSuper(o,objects);
        }catch(Exception e) {
            e.printStackTrace();;
            throw  e;
        }finally {
            System.out.println("after");
        }

        return result;
    }
}
